package com.naiterui.ehp.bs.emr.utils.his.param.resp;

import cn.hutool.json.JSONObject;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;

/**
 * @author yiren
 * @since 2022/1/25
 */
@Data
@Builder
public class CaseResp {
	/**
	 * 就诊时间
	 */
	private String vistingTime;

	/**
	 * 就诊人姓名
	 */
	private String inquirerName;

	/**
	 * 性别
	 */
	private String gender;

	/**
	 * 年龄
	 */
	private String age;

	/**
	 * 主诉内容
	 */
	private String diseasesContent;

	/**
	 * 现病史
	 */
	private String presentDisease;

	/**
	 * 既往史
	 */
	private String pastHistory;

	/**
	 * 过敏史
	 */
	private String allergy;

	/**
	 * 临床诊断
	 */
	private String diagnosis;

	/**
	 * 医生名称
	 */
	private String doctorName;

	/**
	 * 科室名称
	 */
	private String departmentName;

	public static CaseResp of (JSONObject object){
		String departmentName = object.getStr("ks");
		String zs = object.getStr("zs");
		return CaseResp.builder()
				.vistingTime(object.getStr("visit_time"))
				.inquirerName(object.getStr("name"))
				.gender("1".equals(object.getStr("gender")) ? "男" : "女")
				.age(object.getStr("age"))
				.diseasesContent(zs != null ? zs.trim().replace("\r\n", "") : "")
				.presentDisease(object.getStr("xbs"))
				.pastHistory(object.getStr("jws"))
				.allergy(object.getStr("gms"))
				.diagnosis(object.getStr("zd"))
				.doctorName(object.getStr("psn_name"))
				.departmentName(departmentName != null ? departmentName.trim() : "")
				.build();
	}
}
